﻿@using System.Web.UI.WebControls
@using DevExpress.Web.ASPxClasses
@using DevExpress.Web.ASPxEditors
@using DevExpress.Web.Mvc
@using DevExpress.Web.Mvc.UI
@using Dogshow.Web.Controllers
@using Dogshow.Web.Utils
@model Dogshow.Model.Kinolog

@{
    var labelWidth = Unit.Pixel(120);
    var editorWidth = Unit.Pixel(180);
}

@using (Ajax.BeginForm("DodajKinologa", "Psi", new AjaxOptions { HttpMethod = "POST", OnSuccess = "onSuccessDodajKinologa" }/*, new {@class = "edit_form", style="width: 200px;"}*/))
{
    @Html.DevExpress().PopupControl(s =>
    {
        s.Name = "UnosKinologaPopup";
        s.Modal = true;
        s.AllowResize = false;
        s.HeaderText = "Unos kinologa";
        s.ShowHeader = true;
        s.Width = Unit.Pixel(356);
        s.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
        s.PopupVerticalAlign = PopupVerticalAlign.WindowCenter;
        s.SetContent(() =>
        {
            ViewContext.Writer.WriteLine("<div class='line'>");

            @Html.DevExpress().Label(label =>
            {
                label.Text = "Ime i prezime:";
                label.Style.Add("float", "left");
                label.Style.Add(HtmlTextWriterStyle.Display, "block");
                label.Style.Add(HtmlTextWriterStyle.PaddingTop, "4px");
                label.Width = labelWidth;
                label.AssociatedControlName = "ImeIPrezime";
            }).Render();

            @Html.DevExpress().TextBox(textBox =>
            {
                textBox.Name = "ImeIPrezime";
                textBox.Properties.ConvertEmptyStringToNull = true;
                textBox.ShowModelErrors = true;
                textBox.Width = editorWidth;
                textBox.Style.Add("float", "left");
                textBox.Style.Add(HtmlTextWriterStyle.Display, "block");
            }).Bind(Model.ImeIPrezime).Render();

            ViewContext.Writer.WriteLine("</div>");
            
            ViewContext.Writer.WriteLine("<div class='line'>");

                @Html.DevExpress().Label(label =>
                {
                    label.Text = "Adresa:";
                    label.Style.Add("float", "left");
                    label.Style.Add(HtmlTextWriterStyle.Display, "block");
                    label.Style.Add("clear", "left");
                    label.Style.Add(HtmlTextWriterStyle.PaddingTop, "4px");
                    label.Width = labelWidth;
                    label.AssociatedControlName = "Adresa";
                }).Render();
                @Html.DevExpress().TextBox(textEdit => 
                {
                  textEdit.Name = "Adresa";
                  textEdit.Properties.ConvertEmptyStringToNull = true;
                  textEdit.ShowModelErrors = true;
                  textEdit.Width = editorWidth;
                  textEdit.Style.Add("float", "left");
                  textEdit.Style.Add(HtmlTextWriterStyle.Display, "block");
                  textEdit.Style.Add(HtmlTextWriterStyle.MarginTop, "4px");
                }).Bind(Model.Adresa).Render();            
            ViewContext.Writer.WriteLine("</div>");

            ViewContext.Writer.WriteLine("<div class='line'>");

                @Html.DevExpress().Label(label =>
                {
                    label.Text = "Telefon:";
                    label.Style.Add("float", "left");
                    label.Style.Add(HtmlTextWriterStyle.Display, "block");
                    label.Style.Add("clear", "left");
                    label.Style.Add(HtmlTextWriterStyle.PaddingTop, "4px");
                    label.Width = labelWidth;
                    label.AssociatedControlName = "Telefon";
                }).Render();


                @Html.DevExpress().TextBox(textEdit => 
                {
                  textEdit.Name = "Telefon";
                  textEdit.Properties.ConvertEmptyStringToNull = true;
                  textEdit.ShowModelErrors = true;
                  textEdit.Width = editorWidth;
                  textEdit.Style.Add("float", "left");
                  textEdit.Style.Add(HtmlTextWriterStyle.Display, "block");
                  textEdit.Style.Add(HtmlTextWriterStyle.MarginTop, "4px");
                }).Bind(Model.Telefon).Render();
            
            ViewContext.Writer.WriteLine("</div>");

            ViewContext.Writer.WriteLine("<div class='line'>");
            
                @Html.DevExpress().Label(label =>
                {
                    label.Text = "Mesto:";
                    label.Style.Add("float", "left");
                    label.Style.Add(HtmlTextWriterStyle.Display, "block");
                    label.Style.Add("clear", "left");
                    label.Style.Add(HtmlTextWriterStyle.PaddingTop, "4px");
                    label.Width = labelWidth;
                    label.AssociatedControlName = "IdMesta";
                }).Render();

                @Html.DevExpress().ComboBox(combobox =>
                {
                    combobox.Name = "IdMesta";
                    combobox.Width = editorWidth;
                    combobox.Style.Add("float", "left");
                    combobox.Style.Add(HtmlTextWriterStyle.Display, "block");
                    combobox.Style.Add(HtmlTextWriterStyle.MarginTop, "4px");
                    combobox.Properties.ValueType = typeof(int);
                    combobox.Properties.ValueField = "Id";
                    combobox.Properties.TextField = "Naziv";
                    combobox.Properties.IncrementalFilteringMode = IncrementalFilteringMode.Contains;
                    combobox.Properties.Columns.Add("PostanskiBroj", "Poštanski broj");
                    combobox.Properties.Columns.Add("Naziv", "Naziv");
                    //combobox.Properties.FilterMinLength = 2;
                    combobox.CallbackRouteValues = new { Controller = "Mesta", Action = "MestaComboPartial" };
                    combobox.Properties.EnableCallbackMode = true;
                    combobox.Properties.DisplayFormatString = "{0} {1}";
                    combobox.ShowModelErrors = true;
                }).BindList(MestaController.FiltrirajMesta, MestaController.FiltrirajMestoPoId)
                  .BindList(MestaController.VratiMestoPoId(Model.IdMesta))
                  .Bind(Model.IdMesta).Render();
            
            ViewContext.Writer.WriteLine("</div>");

            ViewContext.Writer.WriteLine("<div class='line'>");
            
            @Html.DevExpress().Button(button =>
            {
                button.Name = "btnSacuvaj";
                button.Text = "Sačuvaj";
                button.Style.Add("float", "left");
                button.Style.Add("clear", "left");
                button.Style.Add(HtmlTextWriterStyle.Margin, "4px 0 4px 222px");
                
                button.UseSubmitBehavior = true;
            }).Render();

            ViewContext.Writer.WriteLine("</div>");
        });
    }).GetHtml()
}



      
      

      
      